ga.core.individual
Class IndividualList<T extends IIndividual<T>>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<T>
              extended by ga.core.individual.IndividualList<T>
Type Parameters:
T - The generic type of individuals.
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<T>, java.util.Collection<T>, java.util.List<T>, java.util.RandomAccess

public class IndividualList<T extends IIndividual<T>>
extends java.util.ArrayList<T>

ArrayList for individuals. Adds sorting and validation functions.

Since:
11.08.2012
Author:
Stephan Dreyer
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
IndividualList()
          Creates a new list.
IndividualList(java.util.Collection<? extends T> c)
          Creates a new list by copying the given collection.
 
Method Summary
 boolean isValid(IValidator<T> validator, GAContext context)
          Validates the list with a given validator.
 void sort(boolean descending)
          Sorts the list by using IndividualComparator.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

IndividualList

public IndividualList()
Creates a new list.

Since:
11.08.2012

IndividualList

public IndividualList(java.util.Collection<? extends T> c)
Creates a new list by copying the given collection.

Parameters:
c - Collection to copy.
Since:
11.08.2012
Method Detail

sort

public void sort(boolean descending)
Sorts the list by using IndividualComparator.

Parameters:
descending - Sort descending if true, ascending otherwise.
Since:
11.08.2012

isValid

public boolean isValid(IValidator<T> validator,
                       GAContext context)
Validates the list with a given validator.

Parameters:
validator - The validator to use, nothing will happen if it is null.
context - The GA context.
Returns:
true if all the individuals in the list are valid.
Since:
11.08.2012